Portfolio Learn Month 01 Kali Basics

👤 Day 4: File Ownership & Groups

Ownership
Linux

Permissions are the rules. Ownership is the right to change the rules. 👑


🏦 The Great Analogy: Who Holds the Keys?

Understand ownership through the "Locker" concept:

🏠 Scenario 1: My Locker (I am the Owner)

🏦 Scenario 2: Bank Locker (The Bank is the Owner)

Key Takeaway: You can only change permissions (chmod) if you are the Owner of the file.


🔍 Identifying the Owner

Use ls -l to see who's in charge.

ls -l filename
# Output:
# -rw-r--r-- 1 kali developers 4096 Feb 11 10:00 filename
Output Part Meaning Description
kali User (Owner) The person who owns the file. The "Bank Manager".
developers Group The group associated with the file.

🛠️ Changing Ownership: chown & chgrp

⚠️ Warning: Changing ownership is a powerful action. You almost always need sudo (Root privileges) to do this.

1. Change the Owner (chown)

sudo chown newuser filename
# The old owner loses control, 'newuser' is now the boss.

2. Change the Group (chgrp)

sudo chgrp newgroup filename
# The file now belongs to the 'newgroup'.

3. Change Both at Once

The professional way to do it in one command.

sudo chown user:group filename
# Example:
sudo chown kali:root server.log

❓ Frequently Asked Questions (FAQ)

Q: Does keeping the group as root make the file super powerful?

A: No!
The root group is just a name. It does not grant magical powers to the file itself. It simply means that users in the root group have the group permissions (e.g., read/write) for that file.

Q: Can the root group do anything it wants?

A: No.
Members of the root group can only do what the Owner has permitted for the Group. If the owner sets group permissions to "read-only" (r--), even the root group can only read (unless you are the actual root user, who bypasses everything 😉).


👥 Checking Your Groups

Want to know which clubs you belong to?

groups
# Output example:
# kali adm cdrom sudo dip plugdev users